package com.zycfc.zsf.boot.job.service;

import com.zycfc.zsf.boot.util.time.*;
import java.util.*;
import com.zycfc.zsf.boot.core.common.*;
import com.zycfc.skynet.client.component.*;
import com.zycfc.zsf.boot.util.text.*;
import com.zycfc.zsf.boot.core.web.data.*;
import com.zycfc.zsf.boot.util.http.*;
import org.slf4j.*;

public class DateCollectionService
{
    private static final Logger log;
    
    public static boolean doSpanCollenctMessage(final ZsfJobDatatRequest data) {
        try {
            data.setCompleteDate(DateUtils.getCurTimestamp());
            data.setNamespace(EnvBaseConstants.getInstance().getNamespace());
            data.setApplicationName(EnvBaseConstants.getInstance().getApplicationName());
            SpanUtil.report("job", data.getBatchNo(), (Object)data);
            return true;
        }
        catch (Exception e) {
            DateCollectionService.log.error("data collect error\uff1a{}", (Throwable)e);
            return false;
        }
    }
    
    public static boolean doCollenctMessage(final ZsfJobDatatRequest data) {
        data.setCompleteDate(DateUtils.getCurTimestamp());
        try {
            String url = EnvBaseConstants.getInstance().getBaseNotifyUrl();
            if (StringUtils.isEmpty(url)) {
                return false;
            }
            if (!url.endsWith("/")) {
                url += "/";
            }
            url += "api/job/log";
            data.setNamespace(EnvBaseConstants.getInstance().getNamespace());
            data.setApplicationName(EnvBaseConstants.getInstance().getApplicationName());
            final DataResponse<?> response = (DataResponse<?>)HttpClientUtils.postForObject(url, (Object)data, (Class)DataResponse.class);
            if (!"0000000".equals(response.getCode())) {
                DateCollectionService.log.info("data collect fail:{}", (Object)response.getCode());
                return false;
            }
            return true;
        }
        catch (Exception e) {
            DateCollectionService.log.error("data collect error\uff1a{}", (Throwable)e);
            return false;
        }
    }
    
    static {
        log = LoggerFactory.getLogger((Class)DateCollectionService.class);
    }
}
